package com.md.api.controller;

import com.md.api.common.utils.StringUtils;
import com.md.api.entity.HttpResult;
import com.md.api.entity.PhoneCodeConfirmLaw;
import com.md.api.entity.ShoppingCart;
import com.md.api.entity.SysPcDocInstruction;
import com.md.api.entity.dto.ComposeCommitDto;
import com.md.api.entity.dto.ComposeQueryDto;
import com.md.api.service.CartSevice;
import com.md.api.service.IndexSevice;
import com.md.api.service.SysUserSevice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Slf4j
@RequestMapping("/index")
@RestController
public class IndexController {


	@Resource
	IndexSevice indexSevice;



	@Resource
	SysUserSevice sysUserSevice;


	//首页评论
	@RequestMapping("/evaluation")
	@ResponseBody
	public HttpResult evaluation(HttpServletRequest request,@RequestBody ComposeQueryDto qto) {
		return indexSevice.evaluation(request,qto);
	}

	//图片展示
	@RequestMapping("/pictureShow")
	@ResponseBody
	public HttpResult pictureShow(HttpServletRequest request,@RequestBody ComposeQueryDto qto) {
		return indexSevice.pictureShow(request,qto);
	}

	//图片展示
	@RequestMapping("/picShow")
	@ResponseBody
	public HttpResult picShow(HttpServletRequest request) {
		return indexSevice.picShow();
	}

	@RequestMapping("/switchList")
	public HttpResult switchList() {
		return sysUserSevice.switchList();
	}


	@RequestMapping("/docInstruction")
	@ResponseBody
	public HttpResult docInstruction(HttpServletRequest request, @RequestBody  SysPcDocInstruction instruction) {
		if (StringUtils.isEmpty(instruction.getCode())){
			return HttpResult.PARAM_ERROR;
		}
		return indexSevice.docInstruction(request,instruction);
	}


	@RequestMapping("/phoneCode")
	@ResponseBody
	public HttpResult phoneCode(HttpServletRequest request, @RequestBody  ComposeQueryDto queryDto) {
		return indexSevice.phoneCode(queryDto);
	}

	@RequestMapping("/law")
	@ResponseBody
	public HttpResult law(HttpServletRequest request, @RequestBody PhoneCodeConfirmLaw codeConfirmLaw) {
		if (StringUtils.isEmpty(codeConfirmLaw.getPhoneCode())){
			return HttpResult.PARAM_ERROR;
		}
		return indexSevice.law(codeConfirmLaw);
	}
}
